﻿<UserControl x:Class="GW2PAO.Views.EventTracker.WorldEventView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
             xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
             mc:Ignorable="d" d:DesignHeight="35" d:DesignWidth="200"
             TextOptions.TextFormattingMode="Display">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <converters:EventStateConverter x:Key="StateConverter" />
            <converters:TimespanConverter x:Key="TimeConverter" />
            <converters:TreasureCheckboxConverter x:Key="TreasureConverter" />

        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Hide" Command="{Binding HideCommand}" />
            <Separator />
            <MenuItem Header="{Binding ZoneName}" IsEnabled="False" />
            <MenuItem Header="Copy Waypoint Code" Command="{Binding CopyWaypointCommand}" />
        </ContextMenu>
    </UserControl.ContextMenu>

    <!--Note: DataContext is set by the EventTrackerView-->
    <Border CornerRadius="0" Margin="0,0,5,0" Padding="15,0,5,5" BorderThickness="0,0,0,1">

        <Border.Style>
            <Style TargetType="Border">
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect ShadowDepth="0" Color="LawnGreen"
                                          Opacity="0" BlurRadius="30"/>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=StateTextblock, Path=Text}" Value="Active">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"/>
                                    <DoubleAnimation To="0.25"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"
                                                         BeginTime="00:00:0.5"/>
                                    <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"
                                                         BeginTime="00:00:01"/>
                                    <DoubleAnimation To="0.25"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"
                                                         BeginTime="00:00:01.5"/>
                                    <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"
                                                         BeginTime="00:00:02"/>
                                    <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.5"
                                                         BeginTime="00:00:02.5"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.ExitActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>

        <Border.BorderBrush>
            <LinearGradientBrush Opacity="0.65">
                <GradientStop Color="#FFFFA500" Offset="0.5"/>
                <GradientStop Color="#00FFA500" Offset="1"/>
            </LinearGradientBrush>
        </Border.BorderBrush>

        <Border.Background>
            <SolidColorBrush Color="#01FFFFFF" />
        </Border.Background>

        <Grid Margin="0,5,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <core:OutlinedTextBlock Name="EventName"
                                    Grid.Row="0" Grid.Column="0"
                                    VerticalAlignment="Center" HorizontalAlignment="Left"
                                    Fill="{Binding State, Converter={StaticResource StateConverter}}"
                                    FontSize="13"
                                    Text="{Binding EventName}" />

            <CheckBox Name="ChestIcon" Grid.Column="1"
                      VerticalAlignment="Center" HorizontalAlignment="Center"
                      Margin="0,0,10,0"
                      IsChecked="{Binding IsTreasureObtained}">
                <CheckBox.Style>
                    <Style TargetType="{x:Type CheckBox}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type CheckBox}">
                                    <Image Height="15"
                                           Source="{Binding IsTreasureObtained, Converter={StaticResource TreasureConverter}}"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect ShadowDepth="0"
                                              Color="Gold"
                                              Opacity="0"
                                              BlurRadius="10"/>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </CheckBox.Style>
            </CheckBox>

            <core:OutlinedTextBlock Name="TimerValue"
                                    Grid.Row="0" Grid.Column="2"
                                    VerticalAlignment="Center" HorizontalAlignment="Center"
                                    Fill="{Binding State, Converter={StaticResource StateConverter}}"
                                    FontSize="13"
                                    Text="{Binding TimerValue, Converter={StaticResource TimeConverter}}" />

            <TextBlock Name="StateTextblock" Opacity="0" Foreground="Transparent" Text="{Binding State}" />
        </Grid>
    </Border>
</UserControl>
